import request from "@/utils/request";

// 查询生成表数据
export function getTableList(table, page, size) {
  let data = new FormData();
  data.append("table", table);
  data.append("page", page);
  data.append("size", size);
  return request({
    url: "/service-input/v1/input/queryDbV5",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}

export function queryDbByTName(table, page, size) {
  let data = new FormData();
  data.append("table", table);
  data.append("page", page);
  data.append("size", size);
  return request({
    url: "/service-input/v1/input/queryDbByTNameV5",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}
export function queryTableColumnInfo(db, table) {
  return request({
    url:
      "/service-input/v1/input/queryTableColumnInfoV5?db=" +
      db +
      "&table=" +
      table,
    method: "get",
  });
}
// 模板列表
export function listTemplate(pageNum, pageSize) {
  return request({
    url:
      "/service-input/v1/input/listTemplateV5?pageNum=" +
      pageNum +
      "&pageSize=" +
      pageSize,
    method: "get",
  });
}
// 模板详情
export function listTemplateColumn(data) {
  return request({
    url: "/service-input/v1/input/listTemplateColumnV5?templateId=" + data,
    method: "get",
  });
}

//运行自动化PLUGIN，自动清理
export function getAutoClear(dataSource, plugId, type, createId) {
  let data = new FormData();
  data.append("plugId", plugId);
  data.append("dataSource", dataSource);
  data.append("type", type);
  data.append("createId", createId);
  return request({
    url: "/service-input/v1/input/excutePluginByIdV5",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}
//手动清理条件搜索，有条件
export function getSetCondition(table, cond, rel, page, size) {
  let data = new FormData();
  data.append("table", table);
  data.append("cond", JSON.stringify(cond));
  data.append("rel", rel);
  data.append("page", page);
  data.append("size", size);
  return request({
    url: "/service-input/v1/input/queryDataByCondV5",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}
//手动清理编辑
export function getClearUp(table, id, kv) {
  let data = new FormData();
  data.append("table", table);
  data.append("id", id);
  data.append("kv", kv);
  return request({
    url: "/service-input/v1/input/updateDataV5",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}

//手动清理删除
export function getClearDel(table, id) {
  let data = new FormData();
  data.append("table", table);
  data.append("id", id);
  return request({
    url: "/service-input/v1/input/delDataV5",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}
//获取插件信息
export function getPlugInfo() {
  return request({
    url: "/service-input/v1/input/autoluginListV5",
    method: "get",
  });
}
//列过滤保留获取列表
export function getShowSaveFiltration(table, columns, page, size) {
  return request({
    url:
      "/service-input/v1/input/queryDbWithColumnsV5?table=" +
      table +
      "&columns=" +
      columns +
      "&page=" +
      page +
      "&size=" +
      size,
    method: "get",
  });
}
//列过滤获取列表
export function getShowFiltration(table, columns, page, size, flag) {
  return request({
    url:
      "/service-input/v1/input/queryDbWithColumnsFilterV5?table=" +
      table +
      "&columns=" +
      columns +
      "&page=" +
      page +
      "&size=" +
      size +
      "&flag=" +
      flag,
    method: "get",
  });
}
//从原始表导入数据清洗表
export function moveToClear(table, createId) {
  let data = new FormData();
  data.append("table", table);
  data.append("createId", createId);
  return request({
    url: "/service-input/v1/input/startClearDbV5",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}

//编辑原始数据模板
export function changeMd(templateId, columns) {
  console.log("8888", columns);
  return request({
    url:
      "/service-input/v1/input/editTemplateColumnV5?templateId=" +
      templateId +
      "&columns=" +
      columns,
    method: "get",
  });
}
//关系库导入
export function copyTable(src, tag, columns, createId) {
  return request({
    url:
      "/service-input/v1/input/copySqlBySelV5?src=" +
      src +
      "&tag=" +
      tag +
      "&columns=" +
      columns +
      "&createId=" +
      createId,
    method: "get",
  });
}
//模糊查询接口
export function findTable(table, createTime, type, page, size, state) {
  //type 表状态:(R,C,F)
  return request({
    url:
      "/service-input/v1/input/queryDbByTableNameV5" +
      "?tbname=" +
      table +
      "&pageNum=" +
      page +
      "&pageSize=" +
      size +
      "&createTime=" +
      createTime +
      "&dataType=" +
      type +
      "&dataState=" +
      state,

    method: "get",
  });
}

//模糊查询模板接口
export function findTemplate(tbname, createTime, type, page, size) {
  return request({
    url:
      "/service-input/v1/input/queryDbTemplateTypeByV5" +
      "?tbname=" +
      tbname +
      "&createTime=" +
      createTime +
      "&type=" +
      type +
      "&pageNum=" +
      page +
      "&pageSize=" +
      size,
    method: "get",
  });
}

//模糊查询模板接口
export function findTemplateHnull(createTime, type, page, size) {
  return request({
    url:
      "/service-input/v1/input/queryDbTemplateTypeByV5" +
      "?createTime=" +
      createTime +
      "&type=" +
      type +
      "&pageNum=" +
      page +
      "&pageSize=" +
      size,
    method: "get",
  });
}

//发布接口
export function publishTable(src, dest) {
  let data = new FormData();
  data.append("src", src);
  data.append("dest", dest);
  return request({
    url: "/service-input/v1/input/publishClearTable",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}

//新增字段接口
export function addTemplate(templateId, field, fieldType, fieldSize) {
  let data = new FormData();
  data.append("templateId", templateId);
  data.append("field", field);
  data.append("fieldType", fieldType);
  data.append("fieldSize", fieldSize);
  // data.append("id", schemaid);
  return request({
    url: "/service-input/v1/input/editTemplateColumnV5",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}

//修改字段接口
export function editTemplate(
  templateId,
  field,
  fieldType,
  fieldSize,
  schemaid
) {
  let data = new FormData();
  data.append("templateId", templateId);
  data.append("field", field);
  data.append("fieldType", fieldType);
  data.append("fieldSize", fieldSize);
  data.append("id", schemaid);
  return request({
    url: "/service-input/v1/input/editTemplateColumnV5",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}

//异常值处理
export function OutliersData(table, columns) {
  let data = new FormData();
  data.append("table", table);
  data.append("columns", columns);
  return request({
    url: "/service-input/v1/input/updateTbWithoutExV5",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}

//修改字段接口
export function DelTemplate(templateId, field, fieldType, fieldSize, schemaid) {
  let data = new FormData();
  data.append("templateId", templateId);
  data.append("field", field);
  data.append("fieldType", fieldType);
  data.append("fieldSize", fieldSize);
  data.append("id", schemaid);
  return request({
    url: "/service-input/v1/input/deleteTemplateColumnV5",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}

//数据去重接口
export function updateDb(table, insideColumns, outsideColumns, outsideTable) {
  let data = new FormData();
  data.append("table", table);
  data.append("insideColumns", insideColumns);
  data.append("outsideColumns", outsideColumns);
  data.append("outsideTable", outsideTable);

  // data.append("id", schemaid);
  return request({
    url: "/service-input/v1/input/updateTbWithoutRepV5",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}

//计算列函数获取
export function FxDatil() {
  return request({
    url: "/service-ry/system/fnTemplate/list",
    method: "get",
  });
}
//结算列执行
export function ByFx(table, columns, functionName, newColumn) {
  let data = new FormData();
  data.append("table", table);
  data.append("columns", columns);
  data.append("functionName", functionName);
  data.append("newColumn", newColumn);
  return request({
    url: "/service-input/v1/input/addComputerColumnsV5",

    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}
//修改表状态
export function changeState(table, dataState, flag) {
  let data = new FormData();
  data.append("table", table);
  data.append("dataState", dataState);
  data.append("flag", flag);
  return request({
    url: "/service-input/v1/input/updateDateState",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}
//批量删除
export function delColumnList(tableName, id) {
  let data = new FormData();
  data.append("table", tableName);
  data.append("id", id);
  return request({
    url: "/service-input/v1/input/delDataByMultipleIds",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}
//labs提交
export function updataDataLabs(columns, labs, tbName) {
  let data = new FormData();
  data.append("columns", columns);
  data.append("labs", labs);
  data.append("tbName", tbName);
  return request({
    url: "/service-input/v1/input/updateDensityV5",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}
//labs查询
export function seekAllLabs(cnName, casno, tbName, page, size) {
  return request({
    url:
      "/service-input/v1/input/queryDensityV5" +
      "?cnName=" +
      cnName +
      "&casno=" +
      casno +
      "&tbName=" +
      tbName +
      "&page=" +
      page +
      "&size=" +
      size,
    method: "get",
  });
}
//labs查询
export function seekNameLabs(cnName, tbName, page, size) {
  return request({
    url:
      "/service-input/v1/input/queryDensityV5" +
      "?cnName=" +
      cnName +
      "&tbName=" +
      tbName +
      "&page=" +
      page +
      "&size=" +
      size,
    method: "get",
  });
}
//labs查询
export function seekCasnoLabs(casno, tbName, page, size) {
  return request({
    url:
      "/service-input/v1/input/queryDensityV5" +
      "?casno=" +
      casno +
      "&tbName=" +
      tbName +
      "&page=" +
      page +
      "&size=" +
      size,
    method: "get",
  });
}
//数据清理模板页面数据接口
export function autoPlugInfoList() {
  return request({
    url: "/service-input/v1/input/autoPlugInfoListV5",
    method: "get",
  });
}
//数据清理插件
export function autoPlugInfoLikeList(name, type) {
  return request({
    url:
      "/service-input/v1/input/autoPlugInfoLikeListV5" +
      "?name=" +
      name +
      "&type=" +
      type,
    method: "get",
  });
}
//进人流程新增字段
export function addColumns(table) {
  let data = new FormData();
  data.append("table", table);
  return request({
    url: "/service-input/v1/input/addColumnsV5",
    method: "post",
    data: data,
    headers: {
      "Content-Type": "multipart/form-data;  charset=utf-8;",
    },
  });
}



// 热力学数据总数据
export function getDataCountV5(schema) {
  return request({
    url: '/service-input/scckocMeta/scckocMeta/queryDataCountV5/'+schema,
    method: 'get',
  })
}

